package com.applications.codemash.utility;

import java.text.DateFormat;
import java.util.Comparator;
import java.util.Date;

public class StringDateComparator implements Comparator<String>
{
	@Override
	public int compare(String firstObject, String secondObject)
	{
		try
		{
			DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
			
			Date date1 = formatter.parse(firstObject);
			Date date2 = formatter.parse(secondObject);
			
			return date1.compareTo(date2);
		}
		catch (Exception ex)
		{
			throw new RuntimeException();
		}
	}

}
